<template>
	<view class="container">
		<cu-header bgColor="bg-gradual-blue" :isBack="true"><block slot="content" class="page-name">Diy编辑器</block></cu-header>
		<view>
			<cu-textarea hint="请输入页面配置JSON" @onchange="onInputJSON"></cu-textarea>
		</view>
		<view class="flex flex-wrap padding text-center">
			<button @click="onSeekPage" class="flex-sub cu-btn bg-gradual-blue">查看</button>
			<button @click="onCreatePage" class="flex-sub margin-left-sm cu-btn bg-gradual-orange">新建</button>
		</view>
	</view>
</template>

<script>
	import cuTextarea from '@/components/diy/from/cu-textarea.vue';
	export default {
		components: {
			cuTextarea
		},
		data() {
			return {
				orientation:this.Orientation,
				jsonStr:''
			}
		},
		methods: {
			onInputJSON:function(e){
				this.jsonStr=e;
			},
			onSeekPage: function(e) {
				if(this.jsonStr.length==0){
					this.$util.showAlert("输入内容为空，请检查后重新输入");
					return;
				}
				uni.showLoading({
					title:'正在生成...'
				})
				setTimeout(()=>{
					uni.hideLoading()
					this.$util.showAlert("生成成功！！！");
				},1000)
			},
			onCreatePage: function(e) {
				
				if(this.orientation=='portrait'){
					this.$util.showAlert("当前页面为手机,请切换至电脑端后重试");
					return;
				}
				this.$util.redirectTo('/pages/diy/editor');
				
			}
		}
	}
</script>

<style scoped>
	
</style>
